<?php
declare (strict_types=1);

namespace app\exam\service\admin;

use app\common\service\BaseService;
use app\exam\logic\admin\Popup as PopupLogic;
use think\annotation\Inject;
use think\facade\Request;

/**
 * Class Popup
 *
 * @package app\exam\service\admin
 */
class Popup extends BaseService
{

    /**
     * @Inject()
     *
     * @var PopupLogic
     */
    protected $popupLogic;

    /**
     * get
     *
     * @return \think\Response
     */
    public function getBankIds()
    {
        $dataType = Request::get('data_type/s', '');
        $dataId   = Request::get('data_id/d', 0);

        $data = [];
        if ($dataType && $dataId) {
            $data = $this->popupLogic->get($dataType, $dataId);
        }

        return $this->parseToData($data, 1, '获取成功');
    }

    /**
     * set
     *
     * @return \think\Response
     */
    public function set()
    {
        $dataType = Request::post('data_type/s', '');
        $dataId   = Request::post('data_id/d', 0);
        $bankIds  = Request::post('bank_ids/a', []);

        $data = $this->popupLogic->set($dataType, $dataId, $bankIds);

        return $this->parseToData($data, 1, '设置成功');
    }
}